<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./OL_SDK/include-openlayers-local.js"></script>
    <script src="./libs/gaode.js"></script>
    <script src="./utils/Query.js"></script>
</head>

<body>
    <input type="text" onkeyup="search(event)">
    <!-- 注意：此处只能写event才能接收，写e就是报错e未定义 -->
    <div id="map">
    </div>
    <script>
        const input = document.querySelector('input[type=text]')
        var docLayer = new Zondy.Map.Doc("", "myTestMap1", {

        })
        var map = new ol.Map({
            target: "map",
            layers: [gaode, docLayer],
            view: new ol.View({
                projection: 'EPSG:4326',
                center: [114.30, 30.50],
                zoom: 4
            })
        })
        /* 1、获取输入框的值 */
        function search(e) {
            if (e.key === 'Enter') {
                const value = input.value
                // console.log(value)
                /* 2、执行属性查询 */
                const where = `铁路名称 like '%${value}%' OR 铁路长度 like '%${value}%'`
                const service = {
                    name: 'myTestMap1',
                    layerId: [2],
                }
                Query.queryByAttr({
                    where,
                    service,
                    success(features){
                        console.log(features,'features')
                    }
                })
            }
        }
    </script>
</body>

</html>